//<template>
  <div>
      <div>
          <b>自己班的学生：</b>
          <tr>
          <td>学生姓名</td>
          <td>操作</td>
      </tr>
      <tr v-for="i in stu_list" :key="i.id">
          <td>{{i.stt_name}}</td>
          <td><button @click="put(i.id)">修改</button><button @click="del(i.id)">删除</button><button @click="to(id)">查看此学生的详情</button></td>
      </tr>
      </div>
      <div>
          <b>未分班的学生：</b>
          <tr>
          <td>学生姓名</td>
          <td>操作</td>
      </tr>
      <tr v-for="i in stu_listb" :key="i.id">
          <td>{{i.stt_name}}</td>
          <td><button @click="put_stu(i.id)">添加到自己的班级</button></td>
      </tr>
      </div>
  </div>
</template>

<script>
import axios from 'axios'
export default {
    data(){
        return{
            stu_list:[],
            stu_listb:[]
        }
    },
    methods:{
        get_stu(){
            axios({
                url:'http://127.0.0.1:8000/app03/stu_get/',
                method:'get',
                params:{'id':this.$route.params.id}
            }).then(res=>{
                console.log(res.data)
                
                this.stu_list = res.data.list_true
                this.stu_listb = res.data.list_false
            })
        },
        put_stu(id){
            axios({
                url:'http://127.0.0.1:8000/app03/studendp/',
                method:'get',
                params:{'s_id':id,'t_id':this.$route.params.id}
            }).then(res=>{
                console.log(res.data)
                this.get_stu()
            })

        },
        del(id){
            axios({
                url:'http://127.0.0.1:8000/app03/stu_del/',
                method:'delete',
                params:{'id':id}
            }).then(res=>{
                console.log(res.data)
                this.get_stu()
            })
        },
        put(id){
            this.$router.push({path:'/stuput/'+id})
        },
        to(id){
            this.$router.push({path:'/details/'+id})
        }
    },
    created(){
        this.get_stu()
    }
}
</script>

<style>

</style>